package com.info.zhiduoduo.repository.dto.project;

import com.info.zhiduoduo.common.utils.DateUtil;
import com.info.zhiduoduo.common.utils.ImgBase64Util;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author tianyonghong
 * @create 2022/2/25
 */
@Data
@Accessors(chain = true)
public class ProjectContractDto {

    //项目id
    private Integer projectid;
    //企业id
    private Integer compid;
    //用户id
    private Integer userid;
    //项目名
    private String projectname;
    //项目创建时间
    private Date createtime;
    //项目创建时间
    private Date projectstart;
    //项目金额
    private BigDecimal serviceCharge;
    //项目描述
    private String projectintro;
    //公司名称
    private Integer categoryid;
    //项目商品明细文件路径
    private String commodityDetailFilePath;

    //是否为临时登陆类型: 0:否 1:是
    private int temporaryLogin;
    //电子签名图片存储路径
    private String electronicSignature;

    //公司名称
    private String compname;
    //主体名称
    private String partyName;

    //工作室名称
    private String username;

    //合同名称
    private String contractDocName;
    //合同编号
    private String contractNo;
    //合同日期
    private Date contractDate;
    //合同存放路径
    private String fileFolderPath;

    public static Map<String, Object> ofMap(ProjectContractDto dto) {
        LocalDate localDate = DateUtil.date2LocalDate(dto.getContractDate()).plusYears(1).minusDays(1);
        Date endDate = DateUtil.localDate2Date(localDate);
        Map<String, Object> data = new HashMap<>();
        data.put("contractNo", dto.getContractNo());
        data.put("compname", dto.getCompname());
        data.put("partyName", dto.getPartyName());
        data.put("username", dto.getUsername());
        data.put("serviceCharge", dto.getServiceCharge());
        data.put("contractDate", DateUtil.getString(dto.getContractDate(), DateUtil.FORMAT_STYLE_3));
        data.put("validity", 1);
        data.put("startYear", DateUtil.getString(dto.getContractDate(), "yyyy"));
        data.put("startMonth", DateUtil.getString(dto.getContractDate(), "MM"));
        data.put("startDay", DateUtil.getString(dto.getContractDate(), "dd"));
        data.put("endYear", DateUtil.getString(endDate, "yyyy"));
        data.put("endMonth", DateUtil.getString(endDate, "MM"));
        data.put("endDay", DateUtil.getString(endDate, "dd"));
        data.put("projectname", dto.getProjectname());
        data.put("content", dto.getProjectintro());
        return data;
    }


}
